<template>
  <div class="play-slip">
    <div class="bottom space-between" :class="this.isSpecial?'active':''" @click="checkoutFull">
      <div class="left space-between">
        <div class="img">
          <img
            :src="this.musicMessage.background"
            alt
            :class="playing?'square':''"
          />
        </div>
        <div class="text">
          <span class="title">{{this.musicMessage.music_name}}</span>
          <span class="name">{{this.musicMessage.singer_artistic_name}}</span>
        </div>
      </div>  
      <div class="right">
        <img v-show="!playing" :src="play" @click.stop="changeStatus" alt />
        <img v-show="playing" :src="pause" @click.stop="changeStatus" alt />
        <img :src="musicList" alt  @click.stop="toShowPlaying()"/>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "play-slip",
  data() {
    return {
      store: this.getStore(),
      playing: true,
      songPic: require("@/assets/index/song-pic.png"),
      pause: require("@/assets/index/slip-pause.png"),
      play: require("@/assets/index/slip-play.png"),
      musicList: require("@/assets/index/slip-list.png"),
      isFullPlay: true,
      isShowPlaying:false,
      musicMessage:{}
    };
  },
  props: {
    isPlay: Boolean,
    isFull:Boolean,
    songMes: Object,
    isSpecial:Boolean,
  },
  computed: {
    isFulls: function() {
      return this.store.isFullPlay;
    },
    // musicMessage: function(val) {
    //   console.log(this.store.musicMes,'---this.store.musicMes');
    //   return this.store.musicMes;
    // }
  },
  watch: {
    playing: function(val) {
      this.store.isPlay = val;
      // console.log(this.store.isPlay,'---store--isplay');
      // console.log(this.playing,'---this,playing');
      // console.log(val,'---val');
    },
    isFulls:function(val){
      // console.log(this.store.songMes,'---this.store.songMes;----555');
      // console.log(this.store.isPlay,'---this.store.isPlay---0000000000');
      this.musicMessage = this.store.songMes;
      //  console.log(this.store.isPlay,'---store--isplay');
      this.playing = this.store.isPlay;
    },
    musicMessage:function(val){
      // console.log(val,'-0--val');
      // console.log(this.store.songMes,'---this.store.songMes');
      this.musicMessage = this.store.songMes;
    },
    playingList: function(val) {}
  },
  components: {},
  methods: {
    // 打开播放列表页面
    toShowPlaying(){
      this.isShowPlaying = !this.isShowPlaying;
      this.$emit('fn1',this.isShowPlaying);
    },
    // 点击mini播放器投片切换至全屏播放器
    checkoutFull() {
      this.store.isFullPlay = true;
    },
    changeStatus() {
      this.playing = !this.playing;
      this.store.isPlay = this.playing;
      this.$emit('fn',this.playing);
    }
  },
  created() {
    this.musicMessage = JSON.parse(window.localStorage.getItem("songMes"));
    // console.log(this.musicMessage,'this.musicMessage---play-slip');
    this.$forceUpdate();
    this.playing = this.store.isPlay;
    // console.log( this.store.isPlay,'-- this.store.isPlay---created');
  },
  mounted(){
    // console.log('000');
    // console.log(this.store.isPlay,'---this.store.isPlay==0');
    this.playing = this.store.isPlay;
    if(JSON.stringify(this.store.songMes) == '{}'){
      this.musicMessage = JSON.parse(window.localStorage.getItem('songMes'));
    }
    //  console.log(this.musicMessage,'this.musicMessage---play-slip--mounted');
     this.$forceUpdate();
    this.isFullPlay = this.store.isFullPlay;
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.play-slip {
  @keyframes rotate {
    from {
      transform: rotate(0deg);
      -webkit-transform: rotate(0deg);
      transform-origin: center;
    }
    to {
      transform: rotate(360deg);
      -webkit-transform: rotate(360deg);
      transform-origin: center;
    }
  }
  .square {
    animation: rotate infinite linear 10s;
    -webkit-animation: rotate infinite linear 10s;
    -moz-animation: rotate infinite linear 10s;
  }
  .bottom {
    width: 100%;
    height: 1rem;
    background-color: #fff;
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 1999;
    padding: 0 0.24rem;
    box-sizing: border-box;
    border-top: 0.01rem solid #f8f8f8;
    .left {
      .img {
        // width: 0.8rem;
        // height: 0.8rem;
        // border-radius: 50%;
        img {
          width: 0.8rem;
          height: 0.8rem;
          border-radius: 50%;
        }
      }
      .text {
        display: flex;
        flex-direction: column;
        margin-left: 0.3rem;
        .name{
          color: #999;
        }
      }
    }
    .right {
      display: flex;
      flex-direction: row;
      align-items: center;
      img {
        width: 0.5rem;
        height: 0.5rem;
        margin-left: 0.5rem;
      }
      img:last-child {
        margin-top: 0;
        width: 0.5rem;
        height: 0.5rem;
      }
    }
  }
  .active{
    bottom:1rem;
  }
}
</style>
